home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softdisk Supreme
/
Softdisk Supreme.iso
/
pc
/
DSK Files
/
0-49
/
SD010b.dsk
/
CONNECT4.bas
< prev
next >
Wrap
BASIC Source File
|
2003-06-12
|
3KB
|
83 lines
10 REM **********************
11 REM * CONNECT4 *
12 REM * BY JIM LAFARGUE *
13 REM * SPARTA, NJ *
14 REM **********************
15 REM * SUBMITTED TO *
16 REM * SOFTDISK BY *
17 REM * DR. M.W. FORDICE *
18 REM **********************
19 REM
20 REM
70 TEXT : HOME
80 DIM A(10,9),P$(2)
90 VTAB 10
100 PRINT "CONNECT FOUR PROGRAM"
105 VTAB 14: PRINT "BY JIM LAFARGUE"
110 VTAB 20
120 INPUT "FIRST PLAYER'S NAME ";P$(1)
125 PRINT : INPUT "SECOND PLAYER'S NAME ";P$(2)
140 FOR C = 1 TO 7: FOR R = 1 TO 6:A(C,R) = 0: NEXT R,C
150 GR
160 ONERR GOTO 210
180 W = 0
190 GOSUB 800:W = W +1: IF W >2 THEN W = 1
200 PRINT " ";P$(W);"'S MOVE--COLUMN ";
210 GET C: PRINT C
240 IF C >0 AND C <8 AND C = INT(C) THEN 260
250 PRINT "NO SUCH COLUMN--CHOOSE AGAIN ";: GOTO 210
260 IF A(C,6) = 0 THEN 300
270 PRINT "COLUMN FILLED--CHOOSE AGAIN";: GOTO 210
300 REM ROW SELECTION
310 R = 6
320 IF A(C,R -1) >0 THEN 350
330 R = R -1
340 IF R >1 THEN 320
350 A(C,R) = W
400 REM CHECK FOR WIN OR DRAW
410 FOR C = 1 TO 7: FOR R = 1 TO 6
420 IF A(C,R) -W THEN 470
425 IF A(C +1,R) -W THEN 455
430 IF A(C +2,R) -W THEN 455
435 IF A(C +3,R) = W THEN 900: REM VICTORY
455 IF A(C,R +1) -W THEN 470
460 IF A(C,R +2) -W THEN 470
465 IF A(C,R +3) = W THEN 900
470 NEXT R,C
475 FOR C = 1 TO 4: FOR R = 1 TO 3
480 IF A(C +3,R) -W THEN 520
485 IF A(C +2,R +1) -W THEN 520
490 IF A(C +1,R +2) -W THEN 520
495 IF A(C,R +3) = W THEN 900
520 IF A(C +1,R +1) -W THEN 540
525 IF A(C +2,R +2) -W THEN 540
527 IF A(C,R) -W THEN 540
530 IF A(C +3,R +3) = W THEN 900
540 NEXT R,C
545 E = 0
550 FOR C = 1 TO 7
560 IF A(C,6) = 0 THEN E = 1
570 NEXT C
580 IF E THEN 190
590 FLASH : PRINT "ALL COLUMNS ARE FILLED--IT'S A DRAW"
595 NORMAL
800 REM DISPLAY SUBROUTINE
810 COLOR= 13: REM YELLOW FRAMEWORK
815 VLIN 7,39 AT 1
820 VLIN 7,39 AT 38
825 FOR X = 2 TO 37 STEP 5: VLIN 7,39 AT X
830 NEXT X
835 HLIN 1,38 AT 7: HLIN 1,38 AT 39
840 FOR X = 8 TO 38 STEP 5: HLIN 1,38 AT X: NEXT X
845 FOR C = 1 TO 7: FOR R = 1 TO 6
850 COLOR= A(C,R)
855 FOR X = 1 TO 4: HLIN C *5 -2,C *5 +1 AT (7 -R) *5 +3 +X: NEXT X
860 NEXT R,C: HOME : HTAB 2
865 INVERSE : PRINT SPC( 3);: FOR X = 1 TO 7: PRINT X;: PRINT SPC( 4);: NEXT X
870 PRINT : NORMAL : RETURN
900 GOSUB 800: PRINT " ";: FLASH : PRINT P$(W);" WINS!!": NORMAL
940 PRINT " ANOTHER GAME (Y OR N)? ";
950 GET G$: PRINT G$
960 IF G$ = "Y" THEN 140
970 IF G$ < >"N" THEN 700
980 TEXT : HOME